package priv.leetCode.thread.test1;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/*
 * 作者：m鹏h
 * 时间；2024/6/18 23:19
 * 描述：
 **/
@Slf4j
public class TestThreadWait {

    public volatile   static TestThreadWait testThreadWait;
    private final List<String> collection = new ArrayList<>();

    private TestThreadWait(){

    }

    public static TestThreadWait getTestThreadWait() {
        if (testThreadWait==null){
            synchronized (TestThreadWait.class){
                if (testThreadWait==null){
                    testThreadWait = new TestThreadWait();
                }
            }
        }
        return testThreadWait;
    }
    public void addData1(String data) {
        // 添加数据到集合
        collection.add(data);
        log.error(data);
    }

    public void addData2(String data) {
        // 添加数据到集合
        collection.add(data);
        log.error(data);
    }

    public void addDataSum() {

        log.error(collection.toString());
    }

}
